package com.gzcc.config;

import com.ckfinder.connector.ConnectorServlet;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/** 
* 描述: CKFinderServlet文件管理 
* @Author: Mr.Zhong 
* @Date: 2018/6/13 
*/ 
@Configuration
public class CKFinderServletConfig {

    @Value("${ckeditor.storage.image.path}")
    private String baseDir;
    @Value("${ckeditor.access.image.url}")
    private String baseURL;

    @Bean
    public ServletRegistrationBean connectCKFinder() {
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new ConnectorServlet(), "/ckfinder/core/connector/java/connector.java");
        registrationBean.addInitParameter("XMLConfig", "classpath:/static/ckfinder.xml");
        registrationBean.addInitParameter("debug", "false");
        registrationBean.addInitParameter("configuration", "com.gzcc.configck.CKFinderConfig");
        //初始化ckfinder.xml 配置
        registrationBean.addInitParameter("baseDir", baseDir);
        registrationBean.addInitParameter("baseURL", baseURL);
        return registrationBean;
    }

}
